{layout name="layout" /}

<div class="Hui-article">
    <article class="cl pd-20">
        <form action="" method="post" class="form form-horizontal" id="form-category-add">
            <input type="hidden" name="id" value="{$data.id}">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">* </span>标题：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" value="{$data.title}" placeholder="文章标题,不超过100个字符" id="title" name="title">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">* </span>类别：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <span class="select-box">
                        <select class="select" id="sel_Sub" name="cid">
                            {foreach $categories as $key=>$val}
                            <option value="{$key}" {eq name='data.cid' value="$key" }selected{/eq}>--{$val}--</option>
                            {/foreach}
                        </select>
                    </span>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">* </span>标题图：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" value="{$data.thumb}" id="thumb" name="thumb">
                </div>
                <div class="formControls col-xs-8 col-sm-2">
                    <a href="javascript:;" class="btn btn-primary radius" onClick="addthumb()">
                        <i class="Hui-iconfont">&#xe600;</i>标题图</a>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">&nbsp;关键字&nbsp;：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" value="{$data.keywords}" placeholder="多个关键字用英文半角逗号(,)隔开" id="keywords" name="keywords">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"> 摘 要：</label>
                <div class="formControls col-xs-8 col-sm-6">
                    <textarea name="desc" id="desc" cols="" rows="" class="textarea" placeholder="说点什么...最多输入300个字符" datatype="*10-100" onKeyUp="textarealength(this,300)">{$data.desc}</textarea>
                    <p class="textarea-numberbar">
                        <em class="textarea-length">0</em>/300</p>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span> 内容：</label>
                <div class="formControls col-xs-8 col-sm-6">
                    <script id="editor" type="text/plain" style="width:100%;height:400px;">{$data.content}</script>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">排序: </label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="number" class="input-text" value="{$data.sort}" name="sort" min='0' max='99'>
                    <span class="c-red">* 两位以内整数; 数值越小,排序越靠前</span>
                </div>
                <label class="form-label col-xs-4 col-sm-2">点击量: </label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="number" class="input-text" value="{$data.clicks}" name="clicks" min='0' max='99999999'>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">置顶: </label>
                <div class="formControls col-xs-8 col-sm-2 skin-minimal">
                    <div class="radio-box">
                        <input name="top" type="radio" id="sex-1" value="1" {eq name='data.top' value='1' }checked{/eq}>
                        <label for="sex-1">已置顶</label>
                    </div>
                    <div class="radio-box">
                        <input name="top" type="radio" id="sex-2" value="2" {eq name='data.top' value='2' }checked{/eq}>
                        <label for="sex-2">非置顶</label>
                    </div>
                </div>
                <label class="form-label col-sm-2">状态: </label>
                <div class="formControls col-sm-2 skin-minimal">
                    <div class="radio-box">
                        <input name="status" type="radio" id="sex-1" value="1" {eq name='data.status' value='1' }checked{/eq}>
                        <label for="sex-1">正常</label>
                    </div>
                    <div class="radio-box">
                        <input name="status" type="radio" id="sex-2" value="2" {eq name='data.status' value='2' }checked{/eq}>
                        <label for="sex-2">下线</label>
                    </div>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <div class="col-xs-6 col-sm-8 col-xs-offset-6 col-sm-offset-4">
                    <button class="btn btn-primary radius" type="submit">
                        <i class="Hui-iconfont">&#xe632;</i> 保存</button>
                    <button type="button" class="btn btn-default radius" style="margin-left:40px;" onClick="window.history.back();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </form>
    </article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function () {
        //实例化编辑器   
        var ue = UE.getEditor('editor');

        //提交表单
        $("#form-category-add").submit(function () {
            var note = $("#description").val();

            if (!$("#title").val()) {
                layer.msg('标题不能为空!', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }

            if (getblen(note) > 300) {
                layer.msg('备注过长', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
        })
    });

    //添加缩略图
    function addthumb() {
        layer.open({
            type: 2,
            area: ['700px', '500px'],
            fix: false, //不固定
            maxmin: true,
            shade: 0.4,
            title: '添加缩略图',
            content: '{:url("file_manager/addThumb")}'
        });
    }
</script>
<!--请在上方写此页面业务相关的脚本-->